package com.vonchange.water.pvm.execution;

import com.vonchange.water.pvm.model.definition.BaseActivity;
import com.vonchange.water.pvm.model.runtime.ProcessInstance;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

@Getter
@Setter
public class ActivityExecution implements Serializable {
    /**
     * 节点活动运行实例ID 每进入一次生成一个
     */
    private String executionId;
    private String currentActivityId;
    private ProcessInstance processInstance;
    private transient BaseActivity currentActivity;



    public BaseActivity getCurrentActivity() {
        if(null==currentActivityId){
            return null;
        }
        return this.processInstance.getActivityMap().get(currentActivityId);
    }
    public  Boolean findPvmActivityAuto(){
        return this.getCurrentActivity().getActivityConfig().getAuto();
    }
    public  String findPvmActivityFieldValue(String name){
        //@@null
        return this.getCurrentActivity().getActivityConfig().getFieldMap().get(name).getValue().toString();
    }
    public BaseActivity findPvmActivity(String id){
         return this.processInstance.getActivityMap().get(id);
    }
}
